
#pragma once

#include "Camera.h"
#include "MapReader.h"
#include "Terrain.h"
#include "D3DHeader.h"


class CPicker
{
public:
	CPicker(LPDIRECT3DDEVICE9 pd3dDevice, HWND hwnd, CCamera* pCamera, CTerrain* pTerrain);
	~CPicker();

	//Ray CalcPickingRay(int x, int y);
	Ray CalcPickingRay();
	void Pick();
	BOOL IntersectsSphere(Ray* ray, BoundingSphere* bs);
	BOOL IntersectsSphere(BoundingSphere* bs);

	D3DXVECTOR3 GetPickingPos();


private:
	LPDIRECT3DDEVICE9 m_d3dD3vice;
	HWND m_hWnd;
	CCamera* m_pCamera;
	CTerrain* m_pTerrain;
	cgGame::CMapReader* m_pMapData;

	D3DXVECTOR3 m_trianVertex1;
	D3DXVECTOR3 m_trianVertex2;
	D3DXVECTOR3 m_trianVertex3;

	bool m_isPicked;
	D3DXVECTOR3 m_pickedPos;

};